package one.stand.controller;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.*;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 公司财务/销售
 *
 * @author Administrator
 */
@RequestMapping("crmApi/userTask")
@RestController
public class UserTaskController extends BaseController {

    @PostMapping("addMoneyNum")
    @ApiOperation(value = "录入企业员工本月目标")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "员工名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "targetAmount", value = "目标金额", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "customerNum", value = "独占客户数量", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true, card = true,isBoss = true,paramClass = UserTaskRequest.class)
    public ResultModel addMoneyNum(@RequestAttribute UserTaskRequest request) {
        return crmFegin.addMoneyNum(request);
    }

    @PostMapping("moveCustomer")
    @ApiOperation(value = "企业员工移交客户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "customerIds", value = "客户Id,逗号隔开", required = true, paramType = "String"),
            @ApiImplicitParam(name = "ascriptionId", value = "客户移交后归属人cardId", paramType = "Integer"),
            @ApiImplicitParam(name = "customerState", value = "1:独占客户，2:共享客户", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true, card = true,paramClass =CustomerRequest.class )
    public ResultModel moveCustomer(@RequestAttribute CustomerRequest request) {
        return crmFegin.moveCustomer(request);
    }

    @PostMapping("quitCompany")
    @ApiOperation(value = "企业员工退出企业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "退出员工名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "userId", value = "退出员工userId", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true, card = true,paramClass = BusinessCardRequest.class)
    public ResultModel quitCompany(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.quitCompany(request);
    }

    @PostMapping("dissolutionCompany")
    @ApiOperation(value = "解散企业")
    @ApiController(isLogin = true, company = true,isBoss = true,isParam = false)
    public ResultModel dissolutionCompany(BusinessCardRequest request, @RequestAttribute TokenRequest tokenRequest) {
        BeanUtils.copyProperties(tokenRequest, request);
        return crmFegin.dissolutionCompany(request);
    }

}
